package com.squirrel.michale;

public class Day20240505_LeetCode002708 {

    public long maxStrength(int[] nums) {

        long max = nums[0], min = nums[0];
        for (int i = 1; i < nums.length; ++i) {
            long tmpMax = Math.max(Math.max(nums[i], max), Math.max(nums[i] * max, nums[i] * min));
            long tmpMin = Math.min(Math.min(nums[i], min), Math.min(nums[i] * max, nums[i] * min));
            max = tmpMax;
            min = tmpMin;
        }
        return max;

    }

    public static void main(String[] args) {

        int[] nums = new int[]{3, -1, -5, 2, 5, -9};
        Day20240505_LeetCode002708 leetCode002708 = new Day20240505_LeetCode002708();
        System.out.println(leetCode002708.maxStrength(nums));



    }
}
